home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 25
/
Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso
/
Aminet
/
comm
/
net
/
AMarquee1_48.lha
/
AMarquee
/
examples
/
amarqueedebug.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-04-10
|
7KB
|
180 lines
/*************************************************
AMarqueedebug.rexx
Author: Jeremy Friesner (jaf@chem.ucsd.edu)
An ARexx implementation of amarqueedebug.c. Works pretty much
the same as the C version does! Requires amarquee.library
v46 or higher.
Usage: rx amarqueedebug.rexx [serverName] [portNumber] [logName]
***************************************************/
parse arg serverName portNum logName .
if (serverName == '?') then do
say "Usage: rx amarqueedebug.rexx [serverName] [portNum] [logName]"
say " (defaults args are localhost 2957 amarqueedebug.rexx)"
exit
end
if (length(serverName) = 0) then serverName = 'localhost'
if (length(portNum) = 0) then portNum = 2957
if (length(logName) = 0) then logName = 'amarqueedebug.rexx'
/* We need to trap all the different ways the script could exit,
so that we can be sure any allocated QSessions or QMessages are
freed properly */
signal on error
signal on syntax
signal on halt
signal on break_c
signal on break_f
/* Used to track allocated QSession and QMessage */
session = 0
message = 0
/* Note the offset MUST be -204, and not -30 like in many other
libraries! Note also that we require amarquee.library v46 or higher */
check = addlib('amarquee.library', 0, -204, 46)
/* Here's where we connect to the server... */
say "Connecting to server " || serverName || " on port " || portNum || " as " || logName
session = QNewSession(serverName, portNum, logName)
if (session > 0) then
do
say "Connection successful. Commands are:"
say ""
say "a wildhostpath Access control (default is /#?/#?)"
say "A wildhostpath Access control for incoming messages (default in no access)"
say "m hosts=arg2 Send an active message to hosts"
say "M hosts=string Send an system message to hosts"
say "s path=arg2 Set arg2 node value"
say "S path=arg2 Stream arg2 node value"
say "r path=newlabel Rename arg2 node"
say "D debugstring Send debug string"
say "g wildpath Get a node or nodes"
say "c wildpath Subscribe to a node or nodes"
say "C wildpath Get&Subscribe to a node or nodes"
say "k opID Klear subscriptions (by id or 0 for all)"
say "d wildpath Delete a node or nodes"
say "i Request info packet"
say "p Request ping packet"
say "v # Request new privileges (by code bitchord)"
say "w # Release existing privileges (by code bitchord)"
say "! hosts Kill other clients (requires KILLCLIENTS privilege!)"
say "$ param=string Set a parameter with QSetParam()"
say "? param Get a parameter by name"
say "<enter> Send accumulated transactions (GO!!)"
say ""
say "Press CTRL-F to enter commands, or CTRL-C to quit"
infoOpID = -999
MainLoop:
do forever=1
/* This will block until we get a signal (e.g. CTRL-C) or a QMessage
arrives over our connection. */
message = GetNextQMessage(session, -1, 'SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_F')
if (message > 0) then do
say "QMessage received---------"
say "Status: " || GetQMessageField(message, 'Status') || " (" || QErrorName(GetQMessageField(message, 'Status')) || ")"
say "Error Line: " || GetQMessageField(message, 'ErrorLine')
say "Message ID: " || GetQMessageField(message, 'ID')
say "Path: " || GetQMessageField(message, 'Path')
say "Data: " || GetQMessageField(message, 'Data')
say "DataLen: " || GetQMessageField(message, 'DataLen')
say "ActualLen: " || GetQMessageField(message, 'ActualLen')
/* If QMessage is in response to a QInfoOp, parse out QRunInfo */
if (GetQMessageField(message, 'ID') = infoOpId) then do
say "QRunInfo:"
say "Avail: " || GetQMessageField(message, 'Avail')
say "Alloced: " || GetQMessageField(message, 'Alloced')
say "Allowed: " || GetQMessageField(message, 'Allowed')
say "CurrentPrivs: " || GetQMessageField(message, 'CurrentPrivs')
say "PossiblePrivs: " || GetQMessageField(message, 'PossiblePrivs')
end
call FreeQMessage(session, message)
message = 0
end /* (message > 0) */
else
do
say "GetNextQMessage returned NULL... probably because we caught a signal."
end
end /* (session > 0) */
end
else say "Couldn't connect to server, sorry."
/* Our error handling/cleanup routine starts here */
ERROR:
SYNTAX:
HALT:
BREAK_C:
say "CTRL-C or error detected in line " || sigl
if (message > 0) then do
call FreeQMessage(session, message)
end
if (session > 0) then do
call QFreeSession(session)
end
exit
/* Command processing "subroutine" */
BREAK_F:
say "CTRL-F detected, now reading user commands from console."
done = 0
do while (done = 0)
say "Enter next command, or just press enter to send all queued commands."
parse pull cmd args .
if (length(cmd) = 0) then
do
call QGo(session, 0L) /* 'QGOF_SYNC|QGOF_NOTIFY' could here instead of 0L */
done = 1
end
else
do
/* parse out args if there is an = sign */
parse var args arg1 '=' arg2
res = -100
if (cmd = 'A') then res=QSetMessageAccessOp(session, arg1)
else if (cmd = 'm') then res=QMessageOp(session, arg1, arg2)
else if (cmd = 'M') then res=QSysMessageOp(session, arg1, arg2)
else if (cmd = 'a') then res=QSetAccessOp(session, arg1)
else if (cmd = 's') then res=QSetOp(session, arg1, arg2)
else if (cmd = 'S') then res=QStreamOp(session, arg1, arg2)
else if (cmd = 'r') then res=QRenameOp(session, arg1, arg2)
else if (cmd = 'D') then res=QDebugOp(session, arg1)
else if (cmd = 'g') then res=QGetOp(session, arg1)
else if (cmd = 'd') then res=QDeleteOp(session, arg1)
else if (cmd = 'i') then res=QInfoOp(session)
else if (cmd = 'c') then res=QSubscribeOp(session, arg1)
else if (cmd = 'C') then res=QGetAndSubscribeOp(session, arg1)
else if (cmd = 'k') then res=QClearSubscriptionsOp(session,arg1)
else if (cmd = 'p') then res=QPingOp(session)
else if (cmd = 'v') then res=QRequestPrivilegesOp(session,arg1)
else if (cmd = 'w') then res=QReleasePrivilegesOp(session,arg1)
else if (cmd = '!') then res=QKillClientsOp(session,arg1)
else if (cmd = '?') then res=QGetParameterOp(session,arg1)
else if (cmd = '$') then res=QSetParameterOp(session,arg1,arg2)
if (cmd = 'i') then infoOpId = res
if (res = -100) then say "Unknown command character [" || cmd || "]"
else say "Command processed, opCode was " || res
end
end
say "Sending commands and resuming main loop..."
signal on break_f
signal MainLoop